{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Average Salary Excluding the Minimum and Maximum Salary"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #sorting"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #排序"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: average"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #去掉最低工资和最高工资后的工资平均值"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个整数数组&nbsp;<code>salary</code>&nbsp;，数组里每个数都是 <strong>唯一</strong>&nbsp;的，其中&nbsp;<code>salary[i]</code> 是第&nbsp;<code>i</code>&nbsp;个员工的工资。</p>\n",
    "\n",
    "<p>请你返回去掉最低工资和最高工资以后，剩下员工工资的平均值。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>salary = [4000,3000,1000,2000]\n",
    "<strong>输出：</strong>2500.00000\n",
    "<strong>解释：</strong>最低工资和最高工资分别是 1000 和 4000 。\n",
    "去掉最低工资和最高工资以后的平均工资是 (2000+3000)/2= 2500\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>salary = [1000,2000,3000]\n",
    "<strong>输出：</strong>2000.00000\n",
    "<strong>解释：</strong>最低工资和最高工资分别是 1000 和 3000 。\n",
    "去掉最低工资和最高工资以后的平均工资是 (2000)/1= 2000\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>salary = [6000,5000,4000,3000,2000,1000]\n",
    "<strong>输出：</strong>3500.00000\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 4：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>salary = [8000,9000,2000,3000,6000,1000]\n",
    "<strong>输出：</strong>4750.00000\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>3 &lt;= salary.length &lt;= 100</code></li>\n",
    "\t<li><code>10^3&nbsp;&lt;= salary[i] &lt;= 10^6</code></li>\n",
    "\t<li><code>salary[i]</code>&nbsp;是唯一的。</li>\n",
    "\t<li>与真实值误差在&nbsp;<code>10^-5</code> 以内的结果都将视为正确答案。</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [average-salary-excluding-the-minimum-and-maximum-salary](https://leetcode.cn/problems/average-salary-excluding-the-minimum-and-maximum-salary/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [average-salary-excluding-the-minimum-and-maximum-salary](https://leetcode.cn/problems/average-salary-excluding-the-minimum-and-maximum-salary/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[4000,3000,1000,2000]', '[1000,2000,3000]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return sum(sorted(salary)[1:-1])/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return sum(sorted(salary)[1:-1]) / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.sort()\n",
    "        num = len(salary)\n",
    "        salary.pop(0)\n",
    "        salary.pop()\n",
    "        sum = 0\n",
    "        for i in salary:\n",
    "            sum += i\n",
    "        return sum/(num-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        s1,s2= max(salary),min(salary)\n",
    "        s3=sum(salary)-s1-s2\n",
    "        return s3/(len(salary)-2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary) - max(salary) - min(salary)) / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def insertSort(self,nums:List[int]):\n",
    "        for i in range(1,len(nums)):\n",
    "            tmp = nums[i]\n",
    "            j = i-1\n",
    "            while j>=0:\n",
    "                if nums[j]>tmp:\n",
    "                    nums[j+1] = nums[j]\n",
    "                else: break\n",
    "                j-=1\n",
    "            nums[j+1] = tmp \n",
    "    \n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        self.insertSort(salary)\n",
    "        total = sum(salary)-salary[0]-salary[len(salary)-1]\n",
    "        return total / (len(salary)-2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return sum(sorted(salary)[1:-1]) / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.remove(max(salary))\n",
    "        salary.remove(min(salary))\n",
    "        return sum(salary) / len(salary)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return sum(sorted(salary)[1:-1]) / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        maxValue = max(salary)\n",
    "        minValue = min(salary)\n",
    "        total = sum(salary) - maxValue - minValue\n",
    "        return total / (len(salary) - 2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        a=sorted(salary)\n",
    "        return int(sum(a[1:len(salary) - 1]))/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return mean(sorted(salary)[1:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "         return (sum(salary)-max(salary)-min(salary))/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary) - max(salary) - min(salary)) / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary)-max(salary)-min(salary))/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.pop(salary.index(max(salary)))\n",
    "        salary.pop(salary.index(min(salary)))\n",
    "        n = len(salary)\n",
    "        return sum(salary)/n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.sort()\n",
    "        return sum(salary[1:-1]) / (len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.sort()\n",
    "        return mean(salary[1:len(salary)-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        big=max(salary)\n",
    "        small=min(salary)\n",
    "        n=len(salary)\n",
    "        return (sum(salary)-big-small)/(n-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.sort()\n",
    "        n = len(salary)\n",
    "        add = sum(salary[1:-1])\n",
    "        return add/(n-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "         maxValue = max(salary)\n",
    "         minValue = min(salary)\n",
    "         total = sum(salary) - maxValue - minValue\n",
    "         return total / (len(salary) - 2)\n",
    "         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary = sorted(salary)\n",
    "        return (sum(salary) - salary[-1] - salary[0]) / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        max1=max(salary)\n",
    "        min1=min(salary)\n",
    "        len1=len(salary)-2\n",
    "        return (sum(salary)-max1-min1)/len1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        a = sum(salary)\n",
    "        b = max(salary)\n",
    "        c = min(salary)\n",
    "        d = a-b-c\n",
    "        l = len(salary)\n",
    "        return float(d/(l-2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        maxnum = 1000\n",
    "        minnum = 1000000\n",
    "        total = 0\n",
    "        for i in salary:\n",
    "            total = total+i\n",
    "            if i>maxnum:\n",
    "                maxnum = i\n",
    "            if i<minnum:\n",
    "                minnum = i\n",
    "        return (total-maxnum-minnum)/(len(salary)-2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.sort()\n",
    "        return (sum(salary[1:len(salary) - 1]) / len(salary[1:len(salary) - 1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary) - max(salary)- min(salary)) / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        \n",
    "        return (sum(salary)-max(salary)-min(salary))/(len(salary)-2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        maxValue=max(salary)\n",
    "        minValue=min(salary)\n",
    "        total=sum(salary)-maxValue-minValue\n",
    "        return total/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.remove(max(salary))\n",
    "        salary.remove(min(salary))\n",
    "\n",
    "        return sum(salary)/len(salary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        if len(salary) < 3:\n",
    "            return 0\n",
    "        salary.sort()\n",
    "        a = len(salary)\n",
    "        x = salary[1:a - 1]\n",
    "        b = len(x)\n",
    "        res = sum(x) / b\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        maxVa = max(salary)\n",
    "        minVa = min(salary)\n",
    "        total = sum(salary) - maxVa - minVa\n",
    "        return total / (len(salary) - 2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary)-min(salary)-max(salary))/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return sum(sorted(salary)[1:-1])/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        maxx=salary[0]\n",
    "        minn=salary[0]\n",
    "        summ=0\n",
    "        for i in salary:\n",
    "            summ+=i\n",
    "            if i>maxx:\n",
    "                maxx=i\n",
    "            if i<minn:\n",
    "                minn=i\n",
    "        return (summ-maxx-minn)/(len(salary)-2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.sort()\n",
    "        return (sum(salary) - salary[0] - salary[-1])/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        c=0\n",
    "        a=max(salary)\n",
    "        b=min(salary)\n",
    "        salary.remove(a)\n",
    "        salary.remove(b)\n",
    "        for i in range(len(salary)):\n",
    "            c+=salary[i]\n",
    "        return(c/len(salary))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        n = len(salary)\n",
    "        salary.remove(max(salary))\n",
    "        salary.remove(min(salary))\n",
    "        return sum(salary) / (n-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary)-max(salary)-min(salary))/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        r=len(salary)\n",
    "        for i in range(r):\n",
    "            for j in range(r-i-1):\n",
    "                if salary[j]>salary[j+1]:\n",
    "                    salary[j],salary[j+1]=salary[j+1],salary[j]\n",
    "        return sum(salary[1:r-1])/(r-2)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary[salary.index(min(salary))]=0\n",
    "        salary[salary.index(max(salary))]=0\n",
    "        return sum(salary)/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary) - min(salary) - max(salary)) / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        M1=max(salary)\n",
    "        M2=min(salary)\n",
    "        sum=0\n",
    "        num=0\n",
    "        for i,s in enumerate(salary):\n",
    "            if s!=M1 and s!=M2:\n",
    "                sum+=s\n",
    "                num+=1\n",
    "        return sum/num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return sum(sorted(salary)[1:-1])/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary_sort = sorted(salary, reverse=True)\n",
    "        return sum(salary_sort[1:-1]) / len(salary_sort[1:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary)-max(salary)-min(salary))/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return mean(sorted(salary)[1:-1])\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        maxValue = max(salary)\n",
    "        minValue = min(salary)\n",
    "        total = sum(salary) - maxValue - minValue\n",
    "        return total / (len(salary) - 2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.pop(salary.index(max(salary)))\n",
    "        salary.pop(salary.index(min(salary)))\n",
    "        return sum(num for num in salary) / len(salary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        a = sum(salary)-max(salary)-min(salary)\n",
    "        return a/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary)-max(salary)-min(salary))/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        length=len(salary)\n",
    "        salary.sort()\n",
    "        del salary[0]\n",
    "        del salary[-1]\n",
    "        if length-2==0:\n",
    "            return 0\n",
    "        else:\n",
    "            return sum(salary)/(length-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.sort()\n",
    "        return sum(salary[1:-1])/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        min_salary = min(salary)\n",
    "        max_salary = max(salary)\n",
    "        salary.remove(min_salary)\n",
    "        salary.remove(max_salary)\n",
    "        avg = sum(salary) / len(salary)\n",
    "        return avg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        max_sal = max(salary)\n",
    "        min_sal = min(salary)\n",
    "        total = sum(salary) - max_sal - min_sal\n",
    "\n",
    "        return total / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary = sorted(salary)\n",
    "        return sum(salary[1:len(salary)-1])/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.remove(max(salary))\n",
    "        salary.remove(min(salary))\n",
    "        return mean(salary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return sum(sorted(salary)[1:-1])/(len(salary)-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        salary.sort()\n",
    "        print(salary)\n",
    "        sum = 0\n",
    "        for i in range(1,len(salary) - 1):\n",
    "            sum += salary[i]\n",
    "        return sum / (len(salary) - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def average(self, salary: List[int]) -> float:\n",
    "        return (sum(salary) - min(salary) - max(salary)) / (len(salary)-2)"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
